﻿using System;
using System.Windows;
using Csla.Xaml;
using Accounting.Library;

namespace csla4Skeleton.UI.SL.NghiepVu.TinhGiaThanh.GT_DoDangCK
{
    public partial class GT_DoDangCK_ListViewModel : ViewModel<GT_DoDangCKList>
    {
        public event EventHandler LoadCompleted;
        public GT_DoDangCK_ListViewModel(string mode)
        {
            BeginRefresh("GetGT_DoDangCKList", mode);

        }

        public void GetGT_DoDangCK_ListViewModel(string mode)
        {
            BeginRefresh("GetGT_DoDangCKList", mode);
        }

        public static readonly DependencyProperty SelectedItemProperty =
          DependencyProperty.Register("SelectedItem", typeof(GT_DoDangCKInfo), typeof(GT_DoDangCK_ListViewModel), null);
        public GT_DoDangCKInfo SelectedItem
        {
            get { return (GT_DoDangCKInfo)GetValue(SelectedItemProperty); }
            set { SetValue(SelectedItemProperty, value); }
        }
        protected override void OnRefreshed()
        {
            base.OnRefreshed();
            if (Model != null)
            {

                if (LoadCompleted != null)
                {
                    LoadCompleted(this, new EventArgs());
                }
            }
        }
        public void DeleteGT_DoDangCK(object sender, ExecuteEventArgs e)
        {
            if (e.MethodParameter != null)
            {
                //cast OrderID parameter
                int Khoa = Int16.Parse(e.MethodParameter.ToString());
                this.IsBusy = true;
                Accounting.Library.GT_DoDangCK.DeleteGT_DoDangCK(Khoa, (o, ex) =>
                {
                    BeginRefresh("GetGT_DoDangCKList",BusinessConfiguration.Configuration.GridViewFetchMode);
                });
                this.IsBusy = false;
            }
        }	
    }
}
